package cocurrency.queue;

import java.util.Random;
import java.util.concurrent.BlockingQueue;

/**
 * Created by luzl on 4/6/2017.
 */
public class Producer extends Thread{
    BlockingQueue<String> queue;

    public Producer(BlockingQueue<String> queue){
        this.queue=queue;
    }

    public void run(){
        int i=0;
        while(i<10){
            String message="Now is "+i;
            queue.add(message);
            //System.out.println(message);
            i++;
            try {
                Thread.currentThread().sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
